import PrefabManager from "./PrefabManager";
import Adapter from "./Adapter";
import { UserData, loadUserData } from "./UserData";
import PopUpManager from "./PopUpManager";
import YYYConfig from "./YYYConfig";
import Util from "./Util";

export default class GlobalData{
    static instance:GlobalData;
    manager_prefab:PrefabManager;
    adapter:Adapter;
    userData:UserData;
    popupLayer:PopUpManager;
    config:YYYConfig;
    /**用户id*/
    userid:string;

    constructor(){
        this.userid = "";
        GlobalData.instance=this;
    }

    init(config:YYYConfig){
        this.config = config;
        Util.GameName = config.game_name;
        Util.APIURL = config.http_api_url;
        
        this.adapter = new Adapter();
        this.userData = loadUserData();
        
    }

    /**
     * 加载完资源之后初始化
    */
    init_after_preload():void{
        this.manager_prefab = new PrefabManager(this.config);
        this.popupLayer = new PopUpManager(this.config);
    }
}
